package com;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

/**
 * @author user
 */
public class CodeGenerator {
    private static final String URL="jdbc:mysql://43.138.38.89:3306/stlib?serverTimezone=UTC";
    private static final String USERNAME ="stlib";
    private static final String PASSWORD="123456";
    private static final String AUTHOR="清风";
    private static final String OUTPUTTED="D://test//mybaitsPlusRedissSpringBoot//src//main//java";
    private static final String PARENT ="com.example";
    private static final String SINGLETON_MAP ="D://test//mybaitsPlusRedissSpringBoot//src//main//resources//mapper";
    private static final String ADD_INCLUDE ="barcode,Borrow_books,Borrow_booksss,reader_ids,Return_books,Return_books_copy1,Types_books";

    public static void main(String[] args) {
        FastAutoGenerator.create(URL,USERNAME,PASSWORD)
                .globalConfig(builder -> {
                    builder.author(AUTHOR) // 设置作者
                            .outputDir(OUTPUTTED); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent(PARENT) // 设置父包名
                            .pathInfo(Collections.singletonMap(OutputFile.xml,SINGLETON_MAP)); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude(ADD_INCLUDE); // 设置需要生成的表名
                })
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
